package org.example.com.monitor;

import org.example.com.entity.Inventory;
import org.example.com.entity.Item;

import java.util.List;

public class InventoryMonitor {

    private Inventory inventory;
    private List<Item> allItems;

    public InventoryMonitor(Inventory inventory, List<Item> allItems) {
        this.inventory = inventory;
        this.allItems = allItems;
    }

    public void dailyCheck() {
        System.out.println("【每日库存检查开始】");

        for (Item item : allItems) {
            checkAndAlertReorder(item);
        }

        System.out.println("【每日库存检查结束】");
    }

    private void checkAndAlertReorder(Item item) {
        int currentStock = inventory.getCurrentStock(item);
        int reorderPoint = item.calculateReorderPoint();

        if (currentStock < reorderPoint) {
            System.out.println("⚠️ 警告: 物料 [" + item.getItemName() + "] 当前库存为 " + currentStock + " 已低于再订货点 " + reorderPoint + "，建议立即补货！");
        }
    }
}